
<html>
<head>
<script src="test.js" type="text/javascript" charset="utf-8"></script>

<title>Testing</title>
<script language="Javascript"> 

var ind = 0;
var ind2 = 0;

function Next1() {

   var div1 = document.getElementById("div1");
   
   div1.childNodes[2].nodeValue="Event: " + events.bwEventList.events[ind].summary;
   
   div1.childNodes[4].nodeValue="Date: " + events.bwEventList.events[ind].start.longdate;
   
   div1.childNodes[6].nodeValue="Category: " + events.bwEventList.events[ind].categories[0];
   
   
   ind++;
}
function Previous1() {

	if (ind > 1) {
		ind = ind - 2;

		var div1 = document.getElementById("div1");
   
		div1.childNodes[2].nodeValue="Event: " + events.bwEventList.events[ind].summary;
   
		div1.childNodes[4].nodeValue="Date: " + events.bwEventList.events[ind].start.longdate;
   
		div1.childNodes[6].nodeValue="Category: " + events.bwEventList.events[ind].categories[0];
   
		ind++
	}
}

function Next2() {

   var div2 = document.getElementById("div2");
   
   div2.childNodes[2].nodeValue="Event: " + events.bwEventList.events[ind2].summary;
   
   div2.childNodes[4].nodeValue="Date: " + events.bwEventList.events[ind2].start.longdate;
   
   div2.childNodes[6].nodeValue="Category: " + events.bwEventList.events[ind2].categories[0];
   
   
   ind2++;
}
function Previous2() {

	if(ind2 > 1) {
		ind2 = ind2 - 2;
	
	   var div2 = document.getElementById("div2");
	   
	   div2.childNodes[2].nodeValue="Event: " + events.bwEventList.events[ind2].summary;
	   
	   div2.childNodes[4].nodeValue="Date: " + events.bwEventList.events[ind2].start.longdate;
	   
	   div2.childNodes[6].nodeValue="Category: " + events.bwEventList.events[ind2].categories[0];
	   
	   
	   ind2++;
   }
}
function addElement() {
  var ni = document.getElementById('myDiv');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'my'+num+'Div';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = 'Event: ' + events.bwEventList.events[ind].summary + '<br />Date: ' + events.bwEventList.events[ind].start.longdate;
  
  ni.appendChild(newdiv);
  ind++;
}
function removeElement(divNum) {
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}
</script>
</head>
<body>

<div ID="div1">
	<div ID="div1_1"> </div>
	<div ID="div1_2"> </div>
	<div ID="div1_3"> </div>
	<script language="Javascript">
		Next1();
	</script>

	<form name="form">
	<input type="button" value="Previous"
		onClick="Previous1();">
	<input type="button" value="Next"
		onClick="Next1();">
	</form>

</div>

<div ID="div2">
	<div ID="div2_1"> </div>
	<div ID="div2_2"> </div>
	<div ID="div2_3"> </div>
	<script language="Javascript">
		Next2();
	</script>

	<form name="form">
	<input type="button" value="Previous"
		onClick="Previous2();">
	<input type="button" value="Next"
		onClick="Next2();">
	</form>

</div>

<input type="hidden" value="0" id="theValue" />
<p><a href="javascript:;" onclick="addElement();">Add Some Elements</a></p>
<div ID="myDiv"> </div>


</body>
</html>
